#include <stdio.h>
#include <stdbool.h>

#define MAX(a, b) ((a) > (b) ? (a): (b))
// 贪心
bool canJump(int* nums, int numsSize) {
    if (numsSize == 1) return true;
    int cover = 0;
    for (int i = 0; i <= cover; i++) {
        cover = MAX(cover, i + nums[i]);
        if (cover >= numsSize-1) return true;
    }
    return false;
}


int main(void)
{
    printf("#55. 跳跃游戏\n");
    printf("https://leetcode.cn/problems/jump-game/description/\n");

    int nums[] = {2,2,};
    //int nums[] = {-2};
    bool ret = canJump(nums, sizeof(nums)/sizeof(int));
    printf("ret : %s\n", ret ? "true" : "false");

}

